package com.openjaw.lsy.agent.SPMClientThread;

import com.openjaw.lsy.agent.core.plugin.intercept.ConstructorInterceptPoint;
import com.openjaw.lsy.agent.core.plugin.intercept.InstanceMethodsInterceptPoint;
import com.openjaw.lsy.agent.core.plugin.intercept.enhance.ClassEnhancePluginDefine;
import net.bytebuddy.description.method.MethodDescription;
import net.bytebuddy.matcher.ElementMatcher;

import static net.bytebuddy.matcher.ElementMatchers.named;

public class ClientInstrumentation extends ClassEnhancePluginDefine {
    @Override protected ConstructorInterceptPoint[] getConstructorsInterceptPoints() {
        return new ConstructorInterceptPoint[0];
    }

    @Override protected InstanceMethodsInterceptPoint[] getInstanceMethodsInterceptPoints() {
        return new InstanceMethodsInterceptPoint[] {
            new InstanceMethodsInterceptPoint() {
                @Override public ElementMatcher<MethodDescription> getMethodsMatcher() {
                    return named("applySwitching");
                }

                @Override public String getMethodsInterceptor() {
                    return "com.openjaw.lsy.agent.SPMClientThread.ClientInterceptor";
                }
            },
            new InstanceMethodsInterceptPoint() {
                @Override public ElementMatcher<MethodDescription> getMethodsMatcher() {
                    return named("applyDoNotSend");
                }

                @Override public String getMethodsInterceptor() {
                    return "com.openjaw.lsy.agent.SPMClientThread.ClientInterceptor";
                }
            }
        };
    }

    @Override protected String enhanceClass() {
        return "com.openjaw.serviceProvider.SPMNodeThread";
    }
}
